package com.hsogoo.ultraman.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hsogoo.ultraman.NamespaceConfig;
import com.hsogoo.ultraman.service.ConfigServer;

import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/configServer")
@Slf4j
public class ConfigServerController {



    @Autowired
    private ConfigServer configServer;

    @GetMapping("/pullNamespaceConfig/{env}/{app}/{namespace}")
    public NamespaceConfig pullNamespaceConfig(@PathVariable String env, @PathVariable String app, @PathVariable String namespace){
        log.info("[env={}],[app={}],[namespace={}]", env, app, namespace);
        return configServer.findNamespaceConfig(env, app, namespace);
    }

    @GetMapping("/findAllConfigServer")
    public List<String> findAllConfigServer(){
        return configServer.findAllConfigServer();
    }
}
